package com.gxa.client_shoppings.controller;

import com.gxa.client_shoppings.pojo.*;
import com.gxa.client_shoppings.service.*;
import com.gxa.client_shoppings.utils.JsonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author smile_ZhongXuan
 * @Date 2020/11/13 10:17
 * @Version 1.0
 */
@RestController
@RequestMapping("/shop")
public class ShopSetUpController {

    @Resource
    ShoppingsService shoppingsService = null;
    @Resource
    BasicService basicService = null;
    @Resource
    DisplayService displayService = null;
    @Resource
    ShopProcessService shopProcessService = null;
    @Resource
    GoodsDisplayService goodsDisplayService = null;
    @Resource
    MenuService menuService = null;
    @Resource
    PayTypeService payTypeService = null;
    @Resource
    SendTypeService sendTypeService = null;
    @Resource
    SendAreaService sendAreaService = null;
    JsonResult jsonResult = new JsonResult();

    @PostMapping("/addShopMessage")
    public Map addShopMessage(@RequestBody Shoppings shoppings){
        Integer integer = shoppingsService.addShopMessage(shoppings);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("商店信息添加成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("商店信息添加失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/updateShopMessage")
    public Map updateShopMessage(@RequestBody Shoppings shoppings){
        Integer integer = shoppingsService.updateShopMessage(shoppings);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("商店信息修改成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("商店信息修改失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/listShopMessage")
    public Map listShopMessage(){
        List<Shoppings> listShopMessage = shoppingsService.listShopMessage();
        if (!listShopMessage.equals("") || listShopMessage != null){
            jsonResult.setCode("200");
            jsonResult.setData(listShopMessage);
            jsonResult.setMsg("商店信息列表查询成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("商店信息列表查询失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/deleteShopMessage")
    public Map deleteShopMessage(@RequestParam("id") Integer id){
        Integer integer = shoppingsService.deleteShopMessage(id);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("商店信息删除成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("商店信息删除失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/basicSetUp")
    public Map basicSetUp(@RequestBody Basic basic){
        Integer integer = basicService.basicSetUp(basic);
        if(integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("基本设置信息添加成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("基本设置信息添加失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/displaySetUp")
    public Map displaySetUp(@RequestBody Display display){
        Integer integer = displayService.displaySetUp(display);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("显示设置信息添加成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("显示设置信息添加失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/shopProcess")
    public Map shopProcess(@RequestBody ShopProcess shopProcess){
        Integer integer = shopProcessService.shopProcess(shopProcess);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("购物流程信息添加成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("购物流程信息添加失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/shopDisplaySetUp")
    public Map shopDisplaySetUp(@RequestBody GoodsDisplay goodsDisplay){
        Integer integer = goodsDisplayService.shopDisplaySetUp(goodsDisplay);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("商品显示设置信息添加成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("商品显示设置信息添加失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/menuManagerAdd")
    public Map menuManagerAdd(@RequestBody Menu menu){
        Integer integer = menuService.menuManagerAdd(menu);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("菜单管理新增成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("菜单管理新增失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/menuManagerUpdate")
    public Map menuManagerUpdate(@RequestBody Menu menu){
        Integer integer = menuService.menuManagerUpdate(menu);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("菜单管理更新成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("菜单管理更新失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/menuManagerState")
    public Map menuManagerState(@RequestParam("id") Integer id,@RequestParam("state") Boolean state){
        Integer integer = menuService.menuManagerState(id, state);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("菜单状态更新成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("菜单状态更新失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/menuManagerDelete")
    public Map menuManagerDelete(@RequestParam("id") Integer id){
        Integer integer = menuService.menuManagerDelete(id);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("菜单管理项删除成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("菜单管理项删除失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/menuManagerList")
    public Map menuManagerList(){
        List<Menu> menuManagerList = menuService.menuManagerList();
        if (!menuManagerList.equals("") || menuManagerList != null){
            jsonResult.setCode("200");
            jsonResult.setData(menuManagerList);
            jsonResult.setMsg("菜单管理项查询成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("菜单管理项查询失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/payTypeAdd")
    public Map payTypeAdd(@RequestBody PayType payType){
        Integer integer = payTypeService.payTypeAdd(payType);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("支付方式新增成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("支付方式新增失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/payTypeUpdate")
    public Map payTypeUpdate(@RequestBody PayType payType){
        Integer integer = payTypeService.payTypeUpdate(payType);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("支付方式信息修改成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("支付方式信息修改失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/payTypeState")
    public Map payTypeState(@RequestParam("id") Integer id,@RequestParam("state") Boolean state){
        Integer integer = payTypeService.payTypeState(id, state);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("支付方式状态更改成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("支付方式状态更改失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/payTypeSort")
    public Map payTypeSort(@RequestParam("id") Integer id,@RequestParam("sort") Integer sort){
        Integer integer = payTypeService.payTypeSort(id, sort);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("支付方式排序值更改成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("支付方式排序值更改失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/payTypeList")
    public Map payTypeList(){
        List<PayType> payTypeList = payTypeService.payTypeList();
        if(!payTypeList.equals("") || payTypeList != null){
            jsonResult.setCode("200");
            jsonResult.setData(payTypeList);
            jsonResult.setMsg("支付方式列表查询成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("支付方式列表查询失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/sendTypeAdd")
    public Map sendTypeAdd(@RequestBody SendType sendType){
        Integer integer = sendTypeService.sendTypeAdd(sendType);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("配送方式新增成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("配送方式新增失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/sendTypeUpdate")
    public Map sendTypeUpdate(@RequestBody SendType sendType){
        Integer integer = sendTypeService.sendTypeUpdate(sendType);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("配送方式修改成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("配送方式修改失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/sendTypeState")
    public Map sendTypeState(@RequestParam("id") Integer id,@RequestParam("state") Boolean state){
        Integer integer = sendTypeService.sendTypeState(id, state);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("配送方式状态修改成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("配送方式状态修改失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/sendTypeList")
    public Map sendTypeList(){
        List<SendType> sendTypeList = sendTypeService.sendTypeList();
        if(!sendTypeList.equals("") || sendTypeList != null){
            jsonResult.setCode("200");
            jsonResult.setData(sendTypeList);
            jsonResult.setMsg("配送方式列表查询成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("配送方式列表查询失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/sendAreaAdd")
    public Map sendAreaAdd(@RequestBody SendArea sendArea){
        Integer integer = sendAreaService.sendAreaAdd(sendArea);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("配送区域新增成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("配送区域新增失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/sendAreaUpdate")
    public Map sendAreaUpdate(@RequestBody SendArea sendArea){
        Integer integer = sendAreaService.sendAreaUpdate(sendArea);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("配送区域修改成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("配送区域修改失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/sendAreaDelete")
    public Map sendAreaDelete(@RequestParam("id") Integer id){
        Integer integer = sendAreaService.sendAreaDelete(id);
        if (integer != 0){
            jsonResult.setCode("200");
            jsonResult.setMsg("配送区域删除成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("配送区域删除失败！");
        }
        return jsonResult.getValues();
    }


    @PostMapping("/sendAreaList")
    public Map sendAreaList(){
        List<SendArea> sendAreaList = sendAreaService.sendAreaList();
        if(!sendAreaList.equals("") || sendAreaList != null){
            jsonResult.setCode("200");
            jsonResult.setData(sendAreaList);
            jsonResult.setMsg("配送区域列表查询成功！");
        }else{
            jsonResult.setCode("0");
            jsonResult.setMsg("配送区域列表查询失败！");
        }
        return jsonResult.getValues();
    }
}
